home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / windows / editprog / newvisda.arj / DATAFORM.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-04-28  |  20.9 KB  |  734 lines

  1. VERSION 2.00
  2. Begin Form fDataForm 
  3.    BackColor       =   &H00C0C0C0&
  4.    ClientHeight    =   2520
  5.    ClientLeft      =   1815
  6.    ClientTop       =   3000
  7.    ClientWidth     =   5700
  8.    Height          =   2925
  9.    Icon            =   DATAFORM.FRX:0000
  10.    Left            =   1755
  11.    LinkTopic       =   "Form2"
  12.    MDIChild        =   -1  'True
  13.    ScaleHeight     =   2520
  14.    ScaleWidth      =   5700
  15.    Tag             =   "Dynaset"
  16.    Top             =   2655
  17.    Width           =   5820
  18.    Begin CommonDialog CMD1 
  19.       Left            =   4800
  20.       Top             =   1800
  21.    End
  22.    Begin PictureBox StatBox 
  23.       Align           =   2  'Align Bottom
  24.       BackColor       =   &H00C0C0C0&
  25.       BorderStyle     =   0  'None
  26.       Height          =   270
  27.       Left            =   0
  28.       ScaleHeight     =   282.462
  29.       ScaleMode       =   0  'User
  30.       ScaleWidth      =   5710.271
  31.       TabIndex        =   6
  32.       Top             =   2250
  33.       Width           =   5700
  34.       Begin Data Data1 
  35.          Connect         =   ""
  36.          DatabaseName    =   ""
  37.          Exclusive       =   0   'False
  38.          Height          =   270
  39.          Left            =   0
  40.          Options         =   0
  41.          ReadOnly        =   0   'False
  42.          RecordSource    =   ""
  43.          Top             =   0
  44.          Width           =   5475
  45.       End
  46.    End
  47.    Begin VScrollBar cScrollBar 
  48.       Height          =   2085
  49.       LargeChange     =   3000
  50.       Left            =   7665
  51.       SmallChange     =   300
  52.       TabIndex        =   15
  53.       Top             =   630
  54.       Visible         =   0   'False
  55.       Width           =   255
  56.    End
  57.    Begin PictureBox cFields 
  58.       BackColor       =   &H00C0C0C0&
  59.       BorderStyle     =   0  'None
  60.       Height          =   1065
  61.       Left            =   0
  62.       ScaleHeight     =   1056.48
  63.       ScaleMode       =   0  'User
  64.       ScaleWidth      =   7600.262
  65.       TabIndex        =   10
  66.       TabStop         =   0   'False
  67.       Top             =   630
  68.       Width           =   7605
  69.       Begin TextBox cFieldData 
  70.          BackColor       =   &H00FFFFFF&
  71.          DataSource      =   "Data1"
  72.          ForeColor       =   &H00000000&
  73.          Height          =   285
  74.          Index           =   0
  75.          Left            =   1665
  76.          TabIndex        =   13
  77.          Top             =   0
  78.          Visible         =   0   'False
  79.          Width           =   3255
  80.       End
  81.       Begin CheckBox cFieldCheck 
  82.          BackColor       =   &H00C0C0C0&
  83.          DataSource      =   "Data1"
  84.          Height          =   282
  85.          Index           =   0
  86.          Left            =   1680
  87.          TabIndex        =   12
  88.          Top             =   735
  89.          Visible         =   0   'False
  90.          Width           =   3270
  91.       End
  92.       Begin PictureBox cFieldPicture 
  93.          DataSource      =   "Data1"
  94.          Height          =   282
  95.          Index           =   0
  96.          Left            =   1680
  97.          ScaleHeight     =   255
  98.          ScaleWidth      =   3240
  99.          TabIndex        =   11
  100.          Top             =   315
  101.          Visible         =   0   'False
  102.          Width           =   3270
  103.       End
  104.       Begin Label cFieldName 
  105.          BackColor       =   &H00C0C0C0&
  106.          ForeColor       =   &H00000000&
  107.          Height          =   255
  108.          Index           =   0
  109.          Left            =   105
  110.          TabIndex        =   14
  111.          Top             =   0
  112.          Visible         =   0   'False
  113.          Width           =   1575
  114.       End
  115.    End
  116.    Begin PictureBox FieldHeader 
  117.       Align           =   1  'Align Top
  118.       BackColor       =   &H00C0C0C0&
  119.       BorderStyle     =   0  'None
  120.       Height          =   300
  121.       Left            =   0
  122.       ScaleHeight     =   300
  123.       ScaleMode       =   0  'User
  124.       ScaleWidth      =   5703.403
  125.       TabIndex        =   7
  126.       Top             =   330
  127.       Width           =   5700
  128.       Begin Label FieldValueLabel 
  129.          BackColor       =   &H00C0C0C0&
  130.          Caption         =   " Value:"
  131.          Height          =   252
  132.          Left            =   1680
  133.          TabIndex        =   9
  134.          Top             =   30
  135.          Width           =   2652
  136.       End
  137.       Begin Label FieldHdrLabel 
  138.          BackColor       =   &H00C0C0C0&
  139.          Caption         =   "Field Name:"
  140.          Height          =   252
  141.          Left            =   120
  142.          TabIndex        =   8
  143.          Top             =   30
  144.          Width           =   1212
  145.       End
  146.    End
  147.    Begin PictureBox TopPic 
  148.       Align           =   1  'Align Top
  149.       BackColor       =   &H00C0C0C0&
  150.       BorderStyle     =   0  'None
  151.       Height          =   330
  152.       Left            =   0
  153.       ScaleHeight     =   330
  154.       ScaleWidth      =   5700
  155.       TabIndex        =   0
  156.       Top             =   0
  157.       Width           =   5700
  158.       Begin CommandButton CancelAddBtn 
  159.          Caption         =   "C&ancel"
  160.          Height          =   330
  161.          Left            =   0
  162.          TabIndex        =   17
  163.          Top             =   0
  164.          Visible         =   0   'False
  165.          Width           =   960
  166.       End
  167.       Begin CommandButton RefreshBtn 
  168.          Caption         =   "&Refresh"
  169.          Height          =   330
  170.          Left            =   3780
  171.          TabIndex        =   16
  172.          Top             =   0
  173.          Width           =   960
  174.       End
  175.       Begin CommandButton FindBtn 
  176.          Caption         =   "&Find"
  177.          Height          =   330
  178.          Left            =   2835
  179.          TabIndex        =   5
  180.          Top             =   0
  181.          Width           =   960
  182.       End
  183.       Begin CommandButton CloseBtn 
  184.          Cancel          =   -1  'True
  185.          Caption         =   "&Close"
  186.          Height          =   330
  187.          Left            =   4725
  188.          TabIndex        =   4
  189.          Top             =   0
  190.          Width           =   960
  191.       End
  192.       Begin CommandButton DeleteBtn 
  193.          Caption         =   "&Delete"
  194.          Height          =   330
  195.          Left            =   1890
  196.          TabIndex        =   3
  197.          Top             =   0
  198.          Width           =   960
  199.       End
  200.       Begin CommandButton AddBtn 
  201.          Caption         =   "&Add"
  202.          Height          =   330
  203.          Left            =   0
  204.          TabIndex        =   2
  205.          Top             =   0
  206.          Width           =   960
  207.       End
  208.       Begin CommandButton UpdateBtn 
  209.          Caption         =   "&Update"
  210.          Height          =   330
  211.          Left            =   945
  212.          TabIndex        =   1
  213.          Top             =   0
  214.          Width           =   960
  215.       End
  216.    End
  217. '============================================================================
  218. ' This is a fairly generic form that can be used in most cases with any
  219. ' table. I am sorry if it is confusing. There is a lot of paths to
  220. ' keep track on with adding, editing, browsing, deleting records
  221. ' on populated as well as empty tables. I have added flags where I
  222. ' felt there was no other way to achieve the correct functionality.
  223. ' I am sure that you can improve this form greatly with a little
  224. ' time and understanding of your spcific needs. There is also some
  225. ' recursion that could be trapped but hopefully, the form will be
  226. ' a good starting point for any data control app.
  227. '============================================================================
  228. Dim FldArr() As control
  229. Dim FDS As dynaset
  230. Dim FBM As String                  'form global bookmark
  231. Dim numFlds As Integer
  232. Dim CurrField As Integer
  233. Dim CurrRec As Long
  234. Dim TotRec As Long
  235. Dim JustUsedFind As Integer        'flag for find function
  236. Dim fResizing As Integer           'flag to avoid resize recursion
  237. Dim CancelFlag As Integer          'flag to cancel an addnew
  238. Dim FldTop As Integer
  239. Const EM_NOTHING = 0
  240. Const EM_EDIT = 1
  241. Const EM_ADDNEW = 2
  242. Const FT_TRUEFALSE = 1
  243. Const FT_BYTE = 2
  244. Const FT_INTEGER = 3
  245. Const FT_LONG = 4
  246. Const FT_CURRENCY = 5
  247. Const FT_SINGLE = 6
  248. Const FT_DOUBLE = 7
  249. Const FT_DATETIME = 8
  250. Const FT_STRING = 10
  251. Const FT_BINARY = 11
  252. Const FT_MEMO = 12
  253. Const YES = 6
  254. Const MSGBOX_TYPE = 4 + 48
  255. Sub AddBtn_Click ()
  256.   On Error GoTo AddErr
  257.   Data1.Recordset.AddNew
  258.   Data1.Caption = "New Record"
  259.   CancelAddBtn.Visible = True
  260.   AddBtn.Visible = False
  261.   If Data1.Recordset.RecordCount <> 0 Then
  262.     FBM = Data1.Recordset.Bookmark
  263.     FldArr(0).SetFocus
  264.   End If
  265.   GoTo AddEnd
  266. AddErr:
  267.   MsgBox Error$
  268.   Resume AddEnd
  269. AddEnd:
  270. End Sub
  271. Sub CancelAddBtn_Click ()
  272.   On Error Resume Next
  273.   CancelFlag = True
  274.   If FBM <> "" Then
  275.     Data1.Recordset.Bookmark = FBM
  276.   End If
  277.   If FDS.RecordCount > 0 Then
  278.     SetRecNum
  279.   End If
  280. End Sub
  281. Sub cFieldData_KeyPress (Index As Integer, KeyAscii As Integer)
  282.   'go to next field on an enter keypress
  283.   If KeyAscii = 13 Then
  284.     KeyAscii = 0
  285.     SendKeys "{Tab}"
  286.   End If
  287. End Sub
  288. Sub cFieldPicture_Click (Index As Integer)
  289.   'this toggles the size of a picture control
  290.   'so it mat be viewed or compressed
  291.   If cFieldPicture(Index).Height <= 280 Then
  292.     cFieldPicture(Index).AutoSize = True
  293.   Else
  294.     cFieldPicture(Index).AutoSize = False
  295.     cFieldPicture(Index).Height = 280
  296.   End If
  297. End Sub
  298. Sub cFieldPicture_DblClick (Index As Integer)
  299.   On Error GoTo PicErr
  300.   CMD1.Filter = "Bitmaps (*.bmp)|*.bmp|Icons (*.ico)|*.ico|Metafiles (*.wmf)|*.wmf|All Files (*.*)|*.*"
  301.   CMD1.DialogTitle = "Select a Picture File to Load"
  302.   CMD1.FilterIndex = 1
  303.   CMD1.Action = 1
  304.   If CMD1.Filename <> "" Then
  305.     cFieldPicture(Index).Picture = LoadPicture(CMD1.Filename)
  306.   End If
  307.   GoTo PicEnd
  308. PicErr:
  309.   MsgBox Error$
  310.   Resume PicEnd
  311. PicEnd:
  312. End Sub
  313. Sub CloseBtn_Click ()
  314.   On Error Resume Next
  315.   Unload Me
  316. End Sub
  317. Sub cScrollBar_Change ()
  318.   Dim t As Integer
  319.   t = cScrollBar
  320.   If (t - FldTop) Mod 300 = 0 Then
  321.     cFields.Top = t
  322.   Else
  323.     cFields.Top = ((t - FldTop) \ 300) * 300 + FldTop
  324.   End If
  325. End Sub
  326. Sub Data1_Error (DataErr As Integer, Response As Integer)
  327.   MsgBox "Data error event hit err:" + Error$(DataErr)
  328. End Sub
  329. Sub Data1_RePosition ()
  330.   Dim bm As String
  331.   Dim ds As dynaset
  332.   If Data1.Recordset.RecordCount = 0 And Data1.EditMode <> 2 Then
  333.     Call AddBtn_Click
  334.     Exit Sub
  335.   End If
  336.   If JustUsedFind = True Then
  337.     Set ds = Data1.Recordset.Clone()
  338.     bm = Data1.Recordset.Bookmark
  339.     ds.MoveFirst
  340.     CurrRec = 1
  341.     While ds.Bookmark <> bm
  342.       CurrRec = CurrRec + 1
  343.       ds.MoveNext
  344.     Wend
  345.     JustUsedFind = False
  346.   End If
  347.   SetRecNum
  348. End Sub
  349. Sub Data1_Validate (Action As Integer, Save As Integer)
  350.   On Error GoTo ValErr
  351.   If CancelFlag Then
  352.     Save = False
  353.     CancelFlag = False
  354.     Exit Sub
  355.   End If
  356.   'first check for a move from an addnew or edit record
  357.   If Action < 5 Then
  358.     If Save = True Then      'data changed
  359.       If Data1.EditMode = EM_ADDNEW Then
  360.         If MsgBox("Save New Record?", MSGBOX_TYPE) = YES Then
  361.           TotRec = TotRec + 1
  362.         Else
  363.           Save = False
  364.         End If
  365.       Else
  366.         If MsgBox("Commit Changes?", MSGBOX_TYPE) <> YES Then
  367.           Save = False        'loose changes
  368.         End If
  369.       End If
  370.     End If
  371.     SetRecNum
  372.   End If
  373.   Select Case Action
  374.     Case 1          'First
  375.       CurrRec = 1
  376.     Case 2          'Previous
  377.       If CurrRec = 1 Then Beep
  378.       If CurrRec <> 1 Then CurrRec = CurrRec - 1
  379.     Case 3          'Next
  380.       If CurrRec = TotRec Then Beep
  381.       If CurrRec <> TotRec Then CurrRec = CurrRec + 1
  382.     Case 4          'Last
  383.       CurrRec = TotRec
  384.     Case 5          'AddNew
  385.       'do nothing
  386.     Case 6          'Update
  387.       If Save = True Then
  388.         If Data1.EditMode = EM_ADDNEW Then
  389.           If MsgBox("Save New Record?", MSGBOX_TYPE) = YES Then
  390.             TotRec = TotRec + 1
  391.           Else
  392.             Save = False
  393.           End If
  394.         Else
  395.           If MsgBox("Commit Changes?", MSGBOX_TYPE) <> YES Then
  396.             Save = False
  397.           End If
  398.         End If
  399.       End If
  400.     Case 7          'Delete
  401.       TotRec = TotRec - 1
  402.       SetRecNum
  403.     Case 8
  404.       'set the flag for use in the reposition event
  405.       JustUsedFind = True
  406.     Case 9          'BookMark
  407.       'do nothing"
  408.     Case 10          'Close
  409.       If Save = True Then
  410.         If MsgBox("Commit Changes before Closing?", MSGBOX_TYPE) <> YES Then
  411.           Save = False
  412.         End If
  413.       End If
  414.   End Select
  415.   GoTo ValEnd
  416. ValErr:
  417.   ShowError
  418.   Resume ValEnd
  419. ValEnd:
  420. End Sub
  421. Sub DeleteBtn_Click ()
  422.   On Error GoTo DelErr
  423.   If MsgBox("Delete Current Record?", MSGBOX_TYPE) = YES Then
  424.     Data1.Recordset.Delete
  425.     Data1.Recordset.MoveNext
  426.     FldArr(0).SetFocus
  427.   End If
  428.   GoTo DelEnd
  429. DelErr:
  430.   MsgBox Error$
  431.   Resume DelEnd
  432. DelEnd:
  433. End Sub
  434. Sub FindBtn_Click ()
  435.   On Error GoTo FindErr
  436.   Dim bm As String, findstr As String
  437.   findstr = InputBox("Enter Search Expression:")
  438.   If findstr = "" Then Exit Sub
  439.   If Data1.Recordset.RecordCount > 0 Then
  440.     bm = Data1.Recordset.Bookmark
  441.   End If
  442.   Data1.Recordset.FindFirst findstr
  443.   'return to old record if no match was found
  444.   If Data1.Recordset.NoMatch And bm <> "" Then
  445.     Data1.Recordset.Bookmark = bm
  446.   End If
  447.   GoTo FindEnd
  448. FindErr:
  449.   MsgBox Error$
  450.   Resume FindEnd
  451. FindEnd:
  452.   FldArr(0).SetFocus
  453. End Sub
  454. Sub Form_Load ()
  455.   Dim ds2 As dynaset
  456.   Dim Start, Finish
  457.   On Error GoTo LoadErr
  458.   '-------------------------------------------------------
  459.   'this is where the data control properties get
  460.   'set from whatever source they are coming from
  461.   'in this case, it is form1 controls
  462.   '-------------------------------------------------------
  463.   If gstDataType <> "ODBC" Then
  464.     Data1.DatabaseName = gCurrentDB.Name
  465.   End If
  466.   Data1.Connect = gCurrentDB.Connect
  467.   'determine if a table name or sql statement is used
  468.   If gfFromSQL = True Then
  469.     If gstDynaString = "" Then
  470.       Data1.RecordSource = fSQL.cSQLStatement
  471.     Else
  472.       Data1.RecordSource = gstDynaString
  473.     End If
  474.     Caption = "Dynaset: SQL Statement"
  475.   Else
  476.     Data1.RecordSource = fTables.cTableList
  477.     Caption = "Dynaset: " + UCase(fTables.cTableList)
  478.   End If
  479.   '-------------------------------------------------------
  480.   If gfFromSQL = True And fSQL.cPassThru = 1 Then
  481.     Data1.Options = VBDA_SQLPASSTHROUGH
  482.   End If
  483.   Start = Timer
  484.   Data1.Refresh
  485.   CurrRec = 1
  486.   Set ds2 = Data1.Recordset.Clone()
  487.   If ds2.BOF = False Then
  488.     ds2.MoveLast
  489.     TotRec = ds2.RecordCount
  490.   Else
  491.     TotRec = 0
  492.   End If
  493.   ds2.Close
  494.   Width = 5805
  495.   LoadFields
  496.   Me.Show
  497.   FldArr(0).SetFocus
  498.   SetRecNum
  499.   Finish = Timer
  500.   If VDMDI.PrefShowPerf.Checked Then
  501.     MsgBox CStr(TotRec) + " rows found in " + CStr(Finish - Start) + " seconds!", 48
  502.   End If
  503.   GoTo LoadEnd
  504. LoadErr:
  505.   ShowError
  506.   Unload Me
  507.   Resume LoadEnd
  508. LoadEnd:
  509. End Sub
  510. Sub Form_Resize ()
  511.   On Error Resume Next
  512.   If fResizing = True Then Exit Sub
  513.   Dim h As Integer, i As Integer
  514.   Dim totw As Integer
  515.   fResizing = True
  516.   If WindowState <> 1 And cFieldName(0).Visible = True Then 'not minimized
  517.     'make sure the form is lined up on a field
  518.     h = Height
  519.     If (h - 1320) Mod 300 <> 0 Then
  520.       Height = ((h - 1320) \ 300) * 300 + 1320
  521.     End If
  522.     'resize the status bar
  523.     StatBox.Top = Height - 650
  524.     'resize the scrollbar
  525.     cScrollBar.Height = StatBox.Top - (FieldHeader.Top - FieldHeader.Height) - 600
  526.     cScrollBar.Left = Width - 360
  527.     If FDS.Fields.Count > 10 Then
  528.       cFields.Width = Width - 260
  529.       totw = cScrollBar.Left - 20
  530.     Else
  531.       cFields.Width = Width - 20
  532.       totw = Width - 50
  533.     End If
  534.     FieldHeader.Width = Width - 20
  535.     'widen the fields if possible
  536.     For i = 0 To FDS.Fields.Count - 1
  537.       cFieldName(i).Width = .3 * totw
  538.       FldArr(i).Left = cFieldName(i).Width + 20
  539.       If Data1.Recordset.Fields(i).Type > 9 Then
  540.         FldArr(i).Width = .7 * totw - 270
  541.       End If
  542.     Next
  543.     FieldValueLabel.Left = FldArr(0).Left
  544.   End If
  545.   Data1.Width = StatBox.Width
  546.   fResizing = False
  547. End Sub
  548. Function GetFieldWidth (t As Integer)
  549.   'determines the form control width
  550.   'based on the field type
  551.   Select Case t
  552.     Case FT_TRUEFALSE
  553.       GetFieldWidth = 850
  554.     Case FT_BYTE
  555.       GetFieldWidth = 650
  556.     Case FT_INTEGER
  557.       GetFieldWidth = 900
  558.     Case FT_LONG
  559.       GetFieldWidth = 1100
  560.     Case FT_CURRENCY
  561.       GetFieldWidth = 1800
  562.     Case FT_SINGLE
  563.       GetFieldWidth = 1800
  564.     Case FT_DOUBLE
  565.       GetFieldWidth = 2200
  566.     Case FT_DATETIME
  567.       GetFieldWidth = 2000
  568.     Case FT_STRING
  569.       GetFieldWidth = 3250
  570.     Case FT_MEMO
  571.       GetFieldWidth = 3250
  572.     Case Else
  573.       GetFieldWidth = 3250
  574.   End Select
  575. End Function
  576. Sub LoadFields ()
  577.    Dim t As dynaset
  578.    Dim ds As String        'temp dynaset name string
  579.    Dim ft As Integer
  580.    Dim i As Integer
  581.    On Error GoTo LoadFieldsErr
  582.    Set FDS = Data1.Recordset
  583.    Set t = FDS
  584.    'load the controls on the dynaset form
  585.    numFlds = t.Fields.Count
  586.    ReDim FldArr(numFlds)  As control
  587.    cFieldName(0).Visible = True
  588.    ft = t.Fields(0).Type
  589.    If ft = FT_TRUEFALSE Then
  590.      Set FldArr(0) = cFieldCheck(0)
  591.    ElseIf ft = FT_BINARY Then
  592.      Set FldArr(0) = cFieldPicture(0)
  593.    Else
  594.      Set FldArr(0) = cFieldData(0)
  595.    End If
  596.    FldArr(0).Visible = True
  597.    FldArr(0).Top = 0
  598.    FldArr(0).Width = GetFieldWidth(ft)
  599.    FldArr(0).TabIndex = 0
  600.    On Error Resume Next
  601.    For i = 1 To t.Fields.Count - 1
  602.      cFields.Height = cFields.Height + 300
  603.      Load cFieldName(i)
  604.      cFieldName(i).Top = cFieldName(i - 1).Top + 300
  605.      cFieldName(i).Visible = True
  606.      ft = t.Fields(i).Type
  607.      If ft = FT_TRUEFALSE Then
  608.        Load cFieldCheck(i)
  609.        Set FldArr(i) = cFieldCheck(i)
  610.      ElseIf ft = FT_BINARY Then
  611.        Load cFieldPicture(i)
  612.        Set FldArr(i) = cFieldPicture(i)
  613.      Else
  614.        Load cFieldData(i)
  615.        Set FldArr(i) = cFieldData(i)
  616.      End If
  617.      FldArr(i).Top = FldArr(i - 1).Top + 300
  618.      FldArr(i).Visible = True
  619.      FldArr(i).Width = GetFieldWidth(ft)
  620.      FldArr(i).TabIndex = i
  621.    Next
  622.    On Error GoTo LoadFieldsErr
  623.    'resize main window
  624.    cFields.Top = FieldHeader.Top + FieldHeader.Height
  625.    FldTop = cFields.Top
  626.    cScrollBar = FldTop
  627.    If i <= 10 Then
  628.      Height = i * 300 + 1500
  629.      cScrollBar.Visible = False
  630.    Else
  631.      Height = 4500
  632.      Width = Width + 260
  633.      cScrollBar.Visible = True
  634.      cScrollBar.Min = FldTop
  635.      cScrollBar.Max = FldTop - (i * 300) + 3000
  636.    End If
  637.    'display the field names
  638.    For i = 0 To t.Fields.Count - 1
  639.      cFieldName(i) = UCase(t.Fields(i).Name) + ":"
  640.    Next
  641.    'bind the controls
  642.    On Error Resume Next   'bind even if table is empty
  643.    For i = 0 To t.Fields.Count - 1
  644.      FldArr(i).DataField = t.Fields(i).Name
  645.    Next
  646.    GoTo LoadFieldsEnd
  647. LoadFieldsErr:
  648.    MsgBox Error$
  649.    Resume LoadFieldsEnd
  650. LoadFieldsEnd:
  651. End Sub
  652. Sub MoveBtn_Click (Index As Integer)
  653.   On Error GoTo moveerr
  654.   Dim bm As String
  655.   If Not Data1.Recordset.BOF And Not Data1.Recordset.EOF Then
  656.     bm = Data1.Recordset.Bookmark
  657.   End If
  658.   Select Case Index
  659.     Case 0
  660.       If findval <> "" Then
  661.         Data1.Recordset.FindFirst findval
  662.       Else
  663.         Data1.Recordset.MoveFirst
  664.       End If
  665.     Case 1
  666.       If findval <> "" Then
  667.         Data1.Recordset.FindPrevious findval
  668.       Else
  669.         Data1.Recordset.MovePrevious
  670.       End If
  671.     Case 2
  672.       If findval <> "" Then
  673.         Data1.Recordset.FindNext findval
  674.       Else
  675.         Data1.Recordset.MoveNext
  676.       End If
  677.     Case 3
  678.       If findval <> "" Then
  679.         Data1.Recordset.FindLast findval
  680.       Else
  681.         Data1.Recordset.MoveLast
  682.       End If
  683.   End Select
  684.   'return to old record if no match was found
  685.   If Data1.Recordset.NoMatch And bm <> "" Then
  686.     Data1.Recordset.Bookmark = bm
  687.   End If
  688.   GoTo moveend
  689. moveerr:
  690.   MsgBox Error$
  691.   Resume moveend
  692. moveend:
  693.   FldArr(0).SetFocus
  694. End Sub
  695. Sub RefreshBtn_Click ()
  696.   On Error GoTo RefErr
  697.   Data1.Refresh
  698.   GoTo RefEnd
  699. RefErr:
  700.   ShowError
  701.   Resume RefEnd
  702. RefEnd:
  703. End Sub
  704. Sub SetRecNum ()
  705.   If Data1.EditMode <> 2 Then
  706.     If Data1.Recordset.BOF = True Then
  707.       Data1.Caption = "Record BOF of " & TotRec
  708.     ElseIf Data1.Recordset.EOF = True Then
  709.       Data1.Caption = "Record EOF of " & TotRec
  710.     Else
  711.       Data1.Caption = "Record " & CurrRec & " of " & TotRec
  712.     End If
  713.   End If
  714.   'reset buttons if needed
  715.   If Data1.EditMode <> 2 Then
  716.     CancelAddBtn.Visible = False
  717.     AddBtn.Visible = True
  718.   End If
  719. End Sub
  720. Sub UpdateBtn_Click ()
  721.   On Error GoTo UpdErr
  722.   Dim addflag As Integer
  723.   addflag = Data1.EditMode
  724.   Data1.Recordset.Update
  725.   If addflag = 2 Then
  726.     FDS.MoveLast
  727.   End If
  728.   GoTo UpdEnd
  729. UpdErr:
  730.   ShowError
  731.   Resume UpdEnd
  732. UpdEnd:
  733. End Sub
  734.